package xc;

public class demo1 {
//    static class My_Thread extends Thread{
//        public void run(){
//            for(int i=0;i<5;i++){
//                System.out.println(getName() + "haha");
//            }
//        }
//    }
//
//    public static void main(String[] args) {
//        My_Thread t1 = new My_Thread();
//        My_Thread t2 = new My_Thread();
//
//        t1.setName("t1");
//        t2.setName("t2");
//
//        t1.start();
//        t2.start();
//    }
    static class my_thread implements Runnable{
        public void run(){
            for(int i=0; i<100;i++){
                Thread t = Thread.currentThread();
                System.out.println(t.getName() +  "haha");
            }
        }
}

    public static void main(String[] args) {
        //创建对象，表示多线程要执行的任务
        my_thread mt = new my_thread();

        //创建多线程对象
        Thread t1 = new Thread(mt);
        Thread t2 = new Thread(mt);

        t1.setName("t1");
        t2.setName("t2");

        t1.start();
        t2.start();
    }
}
